package com.wellgoon.test.exam;

import java.util.Iterator;
import java.util.Scanner;
import java.util.TreeSet;

/**
 * 明明的随机数
 */
public class HJ3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个整数：");
        try {
            while (sc.hasNext()) {
                int totalInt = sc.nextInt();
                TreeSet<Integer> ints = new TreeSet<>();
                for (int i = 0; i < totalInt; i++) {
                    int in = (int) (Math.random() * 1000);
                    System.out.println(in);
                    ints.add(in);
                }
                Iterator it = ints.iterator();
                System.out.println("结果是：");
                while (it.hasNext()) {
                    System.out.println(it.next());
                }
                System.out.println("请输入一个整数：");
            }
        } catch (Exception e) {
            System.err.println(""+e.getMessage());
        }
    }
}
